<?php
//初始化

//加载配置文件
//$configpath = ROOT.'config'.DIRECTORY_SEPARATOR.'*.inc.php';
//$config_all=glob($configpath);
//if(!empty($config_all) && is_array($config_all)){
//    foreach ($config_all as $configfile) {
//        if(file_exists($configfile)){
//            require($configfile);
//        }
//    }
//}
  
//加载类
function autoload_class()
{
    $path = ROOT.'program'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'*.php';
    //if(empty ($path)) $path = _LIB."autoclass".DIRECTORY_SEPARATOR;   //如果目录为空
    //$path.="*.class.php";
    $class_all=glob($path);
    if(!empty($class_all) && is_array($class_all)){
        foreach ($class_all as $filename) {
            if(file_exists($filename)){
                include($filename);
                //$classn = new $filename;
                //return $classn;
            }
        }
    }
}

//function __autoload($classname){
//    require ROOT.'program'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.$classname.'.php';
//}

//使用smarty
define('SMARTY_DIR',ROOT.'program'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR);
require(SMARTY_DIR.'Smarty.class.php');

class Action extends Smarty{
    
    public function __construct() {
        parent::__construct();
        $this->caching = false;
        $this->config_dir = ROOT.'skis'.DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR;
        $this->template_dir = ROOT.'skis'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
        $this->compile_dir = ROOT.'skis'.DIRECTORY_SEPARATOR.'compile'.DIRECTORY_SEPARATOR;
        $this->cache_dir = ROOT.'skis'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
        $this->php_handling = SMARTY_PHP_ALLOW;
        
        $this->left_delimiter = "{";
        $this->right_delimiter = "}";
        
        //获取协议
        $pro = explode("/",$_SERVER["SERVER_PROTOCOL"]);
        $pro = strtolower($pro[0].'://'.$_SERVER["SERVER_NAME"]);
        
        define('WEBPATH', $pro.'/');
        define('CSSJSPATH',  $pro.'/skis/templates/include');

        //初始化模板变量
        $this->assign('configinfo',
            array("cssjspath" => CSSJSPATH, //网站css、js的URL
                   "webpath" => WEBPATH
            )
            );
        
        $this->assign("title", "专业服务器维护 网站建设 Linux服务器维护 企业局域网建设 企业级邮件系统建设 异新U 湖南地区");
        
        //显示网站主菜单
        $publicfunca = new publicfunc();
        $channel_list = $publicfunca->get_channel_parent();
        $this->assign("row", $channel_list);
        if($_GET['id']){
            $channel_list = $publicfunca->get_channel_son($_GET['id']);
            $this->assign("row2", $channel_list);
        }
        
        if($_GET['id']){
            $jssetcurrentchannel = $publicfunca->get_current_id($_GET['id']);
            $this->assign("jssetcurrentchannel", $jssetcurrentchannel);
        }
        
        $data = $publicfunca->getdocument();
        $this->assign("recently_document",$data);
    }
}

//加载类
autoload_class();
//设置页面编码为 utf-8
header('Content-type: text/html; charset=utf-8');
?>
